import java.util.Collections;
import java.util.Vector;

public class Tour {
	Vector<Edge> tour;
	Vector<String> sTour;
	double length;
	
	public Tour() {
		tour = new Vector<Edge>();
		sTour = new Vector<String>();
		length = 0.0;
		
	}
	
	public Tour(Vector<Edge> vec, double len) {
		tour = new Vector<Edge>(vec);
		//Collections.copy(vec, tour);
		sTour = new Vector<String>();
		length = len;
	} 
	
	public Tour(Tour t) {
		tour = new Vector<Edge>();
		
		for (int i = 0; i < t.tour.size(); i++) {
			this.tour.add(new Edge(t.tour.get(i).getV1(),t.tour.get(i).getV2(),t.tour.get(i).getWeight()));
		}
		
		this.length = t.length;
	}
	
	public void printTour() {	
		for (int i = 0; i < tour.size(); i++) {
			tour.get(i).getV1().printIndex();
		}
		
		System.out.println(-1);
	}
	
	public void fixPath() {
		Vector<Edge> fixedEdge = new Vector<Edge>();
		Vertex temp;
		int index = 0;
		
		fixedEdge.add(tour.get(0));
		
		while (fixedEdge.size() < tour.size()) {
			temp = fixedEdge.lastElement().getV2(); 
			
			for (int i = 0; i < tour.size(); i++) {
				if (tour.get(i).getV1().getIndex() == temp.getIndex()){
					fixedEdge.add(tour.get(i));
				}
			}
		}
		
		tour = fixedEdge;
	}
}
